/*
 * Alberto Ruiz-Larrea Guillén...11383
 * Erdi Dogruel..................14955
 * Marcos Pérez Martín...........10324
 */

package com.example.database;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;

//This class returns a string with your selected team name
public class getYourTeamString extends AsyncTask<OpenDB, Integer, String> {

	String[] args = new String[] { "1" };

	public getYourTeamString() {
	}

	@Override
	protected String doInBackground(OpenDB... params) {
		OpenDB db = params[0];
		SQLiteDatabase watch = db.getReadableDatabase();
		String[] columns = { OpenDB.id, OpenDB.name, OpenDB.rating,
				OpenDB.selected };

		int num = 0;
		Cursor cursor = watch.query(OpenDB.table1, columns, null, null, null,
				null, null);

		StringBuffer res = new StringBuffer("");
		cursor.moveToFirst();
		while (!cursor.isAfterLast()) {
			int i = (cursor.getInt(3));
			if (i == 1) {
				num = 1;
				res.append(cursor.getString(1));
			}

			cursor.moveToNext();
		}
		cursor.close();

		if (num == 1) {
		} else {
			res.append(0);
		}
		return res.toString();
	}

	@Override
	protected void onPostExecute(String result) {
	}
}